<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%>
<%@ page import = "quiz.Message" %>
<%
	Message m = (Message)request.getAttribute("message");
%>
<jsp:include page="templates/header.jsp" flush="true">
	<jsp:param value = "View Message | Quizzard" name = "title" />
</jsp:include>
<jsp:include page="templates/title_bar.jsp" flush = "true">
	<jsp:param value = "View Message" name = "title" />
</jsp:include>
<div id = "content">
<div class = "center">
<% if (m.getType() != Message.ANNOUNCEMENT) { %>
<div><b>To:</b> <%= m.getRecipient().getName() %></div>
<% } else { %>
<div><b>Announcement</b></div>
<% } %>
<div><b>From:</b> <%= m.getSender().getName() %></div>
<div><b>Body:</b> <%= m.getContent() %></div>
<% 
	 if (m.getType() == Message.CHALLENGE) {
		 out.println("<div><b>Quiz:</b> <a href = \"ShowSelectedQuiz?id="+m.getChallengedQuiz().getID()+"\">"+m.getChallengedQuiz().getName()+"</a></div>");
	 } else if (m.getType() == Message.REQUEST) {
		 out.println("<a href = \"AcceptFriend?friendID="+m.getSender().getID()+"&messageID="+m.getID()+"\"><span class = \"btn\">Accept friend request</span></a>");
	 }

%>
</div>
</div>
<jsp:include page="templates/footer.jsp" flush="true" />